'''
Created on 2010-2-12

@author: summit
'''

from Object import *

class Iterator(Object):
    '''
    A iterator provides the means to access one-by-one all the objects
    in a container. A Python iterator is any class that providers two
    methods called __iter__ and next and that implements the iterator
    protocol which we describe below.
    
    some example:
    c = SomeContainer()
    #...
    i = iter(c) # Equivalent to c.__iter__()
    while True:
        try:
            obj = i.next()
            print obj
        except StopIteration:
            break
    '''
    
    _container = None

    def __init__(self, container):
        '''
        Constructor
        '''
        super(Object, self).__init__()
        self._container = container
    
    def __iter__(self):
        return self
    
    def next(self):
        '''
        the next method must behave as follows:
        1. Each time the next method is called, it returns the next element in 
           the container.
        2. When all the elements in the container have been returned, the next 
           method raises the StopIteration exception.
        '''
        pass
    
    next = AbstractMethod(next)
    
    